<?php
class classOrderForms{
    public function getOrder(){
        $_BasketDetail  = new classBasketsDetail();
        $_Delivery_Type = new classDeliveryType();
        $_Payment_Type  = new classPaimentType();
        $_User_Service  = new classUsersService();

        if($_User_Service->bIsSetUnloggedUser()){
            $_UF = new classUsersForms();
            $UnloggedUserForm = $_UF->getUsersDataSavedInSession();
        }
        else $UnloggedUserForm = '';
        
        $sWinContent  = '<br><b>'._i18n_order_ORDERS_SENDING_.'</b><br><br>';
        $sWinContent .= $UnloggedUserForm;
        $sWinContent .= $testContent;
        $sWinContent .= '<input type="hidden" name="order_operation" id="order_operation">';
        $sWinContent .= '<input type="hidden" name="User_Operation" id="User_Operation">';
        $sWinContent .= '<input type="hidden" name="cbDeliveryType_Selected" id="cbDeliveryType_Selected">';
        $sWinContent .= $_Delivery_Type->getDeliveryList();
        $sWinContent .= '<br><span name="order_payment_container" id="order_payment_container"></span>';
        $sWinContent .= '<br>'.$_BasketDetail->getList();
        $sWinContent .= '<br><b>'._i18n_order_ADDITIONAL_TEXT_.'</b>';
        $sWinContent .= '<br><textarea name="tao_Additional_Text" id="tao_Additional_Text"></textarea><br>';
        $sWinContent .= '<br><span name="order_error_container" id="order_error_container"></span><br>';
        $sWinContent .= '
          <br>
          <a href="'._URL_INACTIVE_ADDR_.'"
            onclick="
              document.getElementById(\'order_operation\').value=\'oo_make_order\';
              classOrder();
              if(document.getElementById(\'cbDeliveryType\').value!=\'0\')
                if(document.getElementById(\'cbPaymentType\').value!=\'0\'){
                    setTimeout(
                        function(){
                            document.getElementById(\'basket_Clear_Session\').value=\'YES\';
                            classBasket();
                            document.getElementById(\'User_Operation\').value=\'jsd_UO_DeleteDataFromSessToMakeOrderWithoutRegistring\';
                            classUsers();
                        },100
                    );
                }
            "
          >
            '._i18n_order_SEND_ORDER_.'
          </a>
          <br>
          <br>
        ';
        $sWinContent .= '<br>'._i18n_order_YOU_CAN_PRINT_YOUR_ORDER_AFTER_SENDING_.'<br>';

        return $sWinContent;
    }

    public function getLogin(){
        function getLinkToSendOrderWithoutRegistring(){
            $result = '';
            if(_SEND_ORDER_WITHOUT_REGISTRING_=='YES'){
                $result = ', '._i18n_order_OR_YOU_CAN_SEND_ORDER_WITHOUT_REGISTRATION_;
                $result.= '
                    <a
                    href="'._URL_INACTIVE_ADDR_.'"
                    onclick="
                      document.getElementById(\'User_Operation\').value = \'jsd_UO_ShowFormToMAkeOrderWithoutRegistring\';
                      classUsers();
                    "
                    >'._i18n_order_YOU_CAN_FIND_FORM_HERE_.'</a>
                ';
            }
            return $result;
        }
        $_UserFrm = new classUsersForms();
        $sWinContent  = '<br><br><b>'._i18n_order_YOU_HAVE_TO_BE_LOGGED_BEFORE_SENDING_YOUR_ORDER_.'</b>';
        $sWinContent .= getLinkToSendOrderWithoutRegistring();
        $sWinContent .= '<br><br>';
        $sWinContent .= $_UserFrm->getLoginForm();
        $sWinContent .= '
          <br>'._i18n_order_IF_YOU_DONT_HAVE_REGISTERED_YOUR_USER_ACCOUNT_YOU_HAVE_TO_REGISTER_IT_.'
          <a 
            href="'._URL_INACTIVE_ADDR_.'"
            onclick="
              document.getElementById(\'User_Operation\').value = \'jsd_UO_ShowRegisterForm\';
              classUsers();
            "
          >'._i18n_order_HERE_.'</a>
          <br><br>
        ';

        return $sWinContent;
    }
    
    public function getResultAfterOrderSent_Successull($OrderID){
        $_OS = new classOrderService();
        $OrderNo = $_OS->getOrderNO($OrderID);
        $links = '';
        $accessInfo = '';
        
        if($_OS->getWasOrderMadeByRegisteredUser($OrderID)){
            $accessInfo = _i18n_order_YOU_CAN_SEE_LIST_OF_YOUR_ORDERS_IN_THE_SECTION_LIST_OF_ORDERS_WHICH_IS_ACCESSIBLE_FROM_USER_MENU_;
            $links = '
                <br>
                <a
                    href="'._URL_INACTIVE_ADDR_.'"
                    onclick="
                      document.getElementById(\'order_operation\').value=\'oo_logout\';
                      document.getElementById(\'shadow_container\').style.visibility=\'hidden\';
                      classOrder();
                "
                >'._i18n_order_MAKE_NEW_ORDER_.'</a>
                <br>
                <a
                    href="'._URL_INACTIVE_ADDR_.'"
                    onclick="
                      document.getElementById(\'User_Operation\').value = \'jsd_UO_LogOut\';
                      classUsers();

                      document.getElementById(\'order_operation\').value=\'oo_logout\';
                      document.getElementById(\'shadow_container\').style.visibility=\'hidden\';
                      classOrder();
                    "
                >'._i18n_order_LOGOUT_.'</a>
                <br>';
        }
        else{
            $links = '
                <br>
                <a
                    href="'._URL_INACTIVE_ADDR_.'"
                    onclick="
                      document.getElementById(\'shadow_container\').style.visibility=\'hidden\';
                      document.getElementById(\'flow_container2\').visibility=\'hidden\';
                      document.getElementById(\'flow_container2\').innerHTML=\'\';
                      
                    "
                >'._i18n_order_CLOSE_.'</a>
                <br>';
        }
        
        return '
          <br>'._i18n_order_RESULT_OF_ORDERS_SENDING_.'
          <br>
          <br>
          '._i18n_order_YOUR_ORDER_WAS_SENT_SUCCESSFUL_AND_IT_WAS_RETRIEVED_FOR_PROCESSING_UNDER_NUMBER_.' <b>'.$OrderNo.'</b>
          <br>
          <br>
          '._i18n_order_WE_WILL_CONTACT_YOU_FOR_ACKNOWLEDGEMENT_IN_WORK_TIME_.'
          <br>
          <br>
          <br>
          '.$accessInfo.'
          <br>
          <br>
          <input type="hidden" name="order_operation" id="order_operation">
          <a 
            href="admin/order_management_print.php?ID='.$OrderID.'"  target="_blank"
          >'._i18n_order_PRINT_ORDER_.'</a>'.
          $links.'
          <br>
        ';        
    }
    
    public function getResultAfterOrderSent_Error(){
        return '
          <br>'._i18n_order_ORDER_SENDING_.'
          <br>
          <br>
          '._i18n_order_ERROR_HAPPEND_IN_SYSTEM_.'
          <br>
          '._i18n_order_WAIT_FOR_WHILE_AND_AFTER_THAT_YOU_CAN_MAKE_ORDER_AGAIN_.'
          <br>
          <br>
          <a href="'._URL_INACTIVE_ADDR_.'"
            onclick="
              document.getElementById(\'shadow_container\').style.visibility=\'hidden\';
              document.getElementById(\'User_Operation\').value = \'jsd_UO_CloseWindow\';
              classUsers();
            "
          >
            '._i18n_user_CLOSE_.'
          </a>
          <br><br>
        ';
    }
}

?>
